//
//  MainAccountHeaderView.swift
//  d11
//
//  Created by peale on 2018/9/17.
//  Copyright © 2018年 Tech_001. All rights reserved.
//

import UIKit

class MainAccountHeaderView: UITableViewHeaderFooterView {
    var bgImgView : UIImageView?
     var nameLabel : UILabel?
    var moneyLabel : UILabel?
    var recoveryLabel : UILabel?
    override init(reuseIdentifier: String?) {
        super.init(reuseIdentifier: reuseIdentifier)
        self.backgroundColor  = UIColor.white
        self.contentView.backgroundColor = UIColor.white
        self.bgImgView = UIImageView.init()
        self.bgImgView?.backgroundColor = UIColor.white
        self.bgImgView?.image = imageNamed("icon_mainAccount_cell_top")
        self.contentView.addSubview(bgImgView!);
        self.bgImgView?.snp.makeConstraints{(make) in
            make.width.equalToSuperview().offset(-10)
            make.height.equalTo(39.5)
            make.centerX.equalTo(self.contentView)
        };
        
    
        self.nameLabel = UILabel.init()
        self.nameLabel?.textColor = HexRGBAlpha(0xBBBEBF, 1)
        self.nameLabel?.font = UIFont.systemFont(ofSize: 15)
        self.nameLabel?.text = "名称"
        self.nameLabel?.textAlignment = NSTextAlignment.left
        self.bgImgView?.addSubview(self.nameLabel!)
        
        self.nameLabel?.snp.makeConstraints{(make) in
            make.left.equalTo(20)
            make.width.equalTo(40)
            make.height.equalToSuperview()
        }
        
        
        self.moneyLabel = UILabel.init()
        self.moneyLabel?.textColor = HexRGBAlpha(0xBBBEBF, 1)
        self.moneyLabel?.font = UIFont.systemFont(ofSize: 15)
        self.moneyLabel?.text = "金额"
        self.moneyLabel?.textAlignment = NSTextAlignment.center
        self.bgImgView?.addSubview(self.moneyLabel!)
        
        self.moneyLabel?.snp.makeConstraints{(make) in
            make.centerX.equalToSuperview()
            make.width.equalTo(40)
            make.height.equalToSuperview()
        }
        
        self.recoveryLabel = UILabel.init()
        self.recoveryLabel?.textColor = HexRGBAlpha(0xBBBEBF, 1)
        self.recoveryLabel?.font = UIFont.systemFont(ofSize: 15)
        self.recoveryLabel?.text = "回收"
        self.recoveryLabel?.textAlignment = NSTextAlignment.right
        self.bgImgView?.addSubview(self.recoveryLabel!)
        
        self.recoveryLabel?.snp.makeConstraints{(make) in
            make.right.equalTo(-27.5)
            make.width.equalTo(40)
            make.height.equalToSuperview()
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    func setData(isList:Bool) -> Void {
        if isList {
             self.moneyLabel?.isHidden = false
             self.recoveryLabel?.isHidden = false
             self.nameLabel?.font = UIFont.systemFont(ofSize: 15)
             self.nameLabel?.text = "名称"
        }else{
            self.moneyLabel?.isHidden = true
            self.recoveryLabel?.isHidden = true
            self.nameLabel?.font = UIFont.systemFont(ofSize: 16)
             self.nameLabel?.text = "转账"
        }
    }
}
